#!/usr/bin/env perl

use lib qw{../config ../lib/perl};
use strict;
use warnings;
use CGI;
use Cwd;
use Util;
use TRFLP;

my $cgi = new CGI;
my $dir = $cgi->param('dir');

Util::open_cgi_shell("Clipping the standard ladder");

print "<b>&gt; cd $TRFLP::data_path/$dir</b>\n";

chdir "$TRFLP::data_path/$dir" or die "Couldn't call 'chdir $TRFLP::data_path/$dir', reason: $!";

foreach my $file ( grep /standard$/, `ls .` ) {
  chomp $file;
  my $command = "octave -qp $TRFLP::lib/octave $TRFLP::bin/clip_ladder.m $file > $file.clipped";
  Util::run_task(*STDOUT, $command);
}

Util::close_cgi_shell();
